<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>

<html xmlns="http://www.w3.org/1999/xhtml">

	<head>

		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

		<title><?php echo C('WEB_TITLE');?></title>

		<link rel="stylesheet" type="text/css" href="/Public/css/common.css"/>

		<link rel="stylesheet" type="text/css" href="/Public/js/layui/css/layui.css" media="all"/>

		<link rel="stylesheet" href="/Public/js/datepicker/datepicker.css"/>

		<link rel="stylesheet" type="text/css" href="/Public/crm/css/index.css"/>

		<link rel="stylesheet" type="text/css" href="/Public/crm/css/style.css"/>

		<link rel="stylesheet" href="<?php echo C('PC_ICON_HTTP');?>">

		<script type="text/javascript" >

			const moduleName = "<?php echo (MODULE_NAME); ?>";

		</script>

        <link rel="stylesheet" href="/Public/js/viewer/css/viewer.min.css">
		
		<link rel="stylesheet" type="text/css" href="/Public/js/select2/select2.css" media="all"/>

		<script type="text/javascript" src="/Public/js/jquery-1.9.1.min.js"></script>
		
		<script type="text/javascript" src="/Public/js/jquery-ui.min.js"></script>

		<script type="text/javascript" src="/Public/js/cookie/jquery.cookie.js"></script>

		<script type="text/javascript" src="/Public/js/lang/<?php echo (getStrToLower(cookie('think_language'))); ?>.js"></script>

		<script type="text/javascript" src="/Public/js/colorpicker.js"></script>

		<script type="text/javascript" src="/Public/js/layer/layer.js"></script>

		<script type="text/javascript" src="/Public/js/layui/layui.js"></script>

        <script type="text/javascript" src="/Public/js/feeldesk.js"></script>

        <script type="text/javascript" src="/Public/crm/js/index.js"></script>

        <script type="text/javascript" src="/Public/js/jquery.nicescroll.js"></script>

		<script type="text/javascript" src="/Public/js/clipboard.min.js"></script>

		<script type="text/javascript" src="/Public/js/select2/select2.min.js"></script>

		<script type="text/javascript" src="/Public/js/select2/jquery.core.js"></script>

	</head>

<body>

<script type="text/javascript" src="/Public/js/datepicker/datepicker.all.js"></script>

<script type="text/javascript" src="/Public/js/datepicker/moment.min.js"></script>

<script type="text/javascript" src="/Public/js/datepicker/datepicker.en.js"></script>

    <div class="fd-right-main">

        

<div class="comment-shade"></div>

<div class="comment-panel hidden" id="comment">

	<header><span><?php echo L('REASON');?>（<?php echo L('NOT_REQUIRED');?>）</span><i class="iconfont icon-guanbi comment-close" title="<?php echo L('CLOSE');?>"></i></header>

	<form action="" id="commentForm" class="layui-form">

		<textarea id='commentEditor' name="reason" cols="30" rows="10" placeholder=""></textarea>

		<div class="submit-comment"><a href="javascript:" class="layui-btn"><?php echo L('SUBMIT');?></a></div>

	</form>

</div>

<div class="customer-detail feeldesk-form pd0 feelcrm-form">

    <div class="customer-detail-content">

        <div class="detail-sidebar sidebar" id="closeCustomerDetail"><i class="iconfont icon-right"></i></div>

		<div class="customer-header">

			<div class="customer-header-name"><span class="iconfont icon-dingdanxiangqing blue8"></span><?php echo ($contract["contract_prefix"]); echo ($contract["contract_no"]); ?></div>

			<div class="customer-header-right">

				<?php if(($detailtype) == "index"): if(($contract["isvalid"]) == "1"): echo FEELCRM('Contract/edit',['id'=>encrypt($contract['contract_id'],'CONTRACT'),'detailtype'=>encrypt('index','CONTRACT')],L('EDITOR'),'feelcrm-commbtn ml5');?>

					<?php else: ?>

						<?php echo FEELCRM('Recover/re_contract',['id'=>encrypt($contract['contract_id'],'CONTRACT')],L('RECOVERY'),'feelcrm-commbtn ml5','batch'); endif; ?>

					<?php echo FEELCRM('Contract/delete',['id'=>encrypt($contract['contract_id'],'CONTRACT'),'detailtype'=>encrypt('index','CONTRACT')],L('DELETE'),'feelcrm-commbtn ml5','trash'); endif; ?>

			</div>

		</div>

		<div class="form-nav">

			<ul>

				<?php if(!empty($isDetailAuthView)): ?><li><a href="<?php echo U('contract/detail',['id'=>encrypt($contract['contract_id'],'CONTRACT'),'detailtype'=>encrypt('index','CONTRACT'),'detail_source'=>$detail_source]);?>" class="form-tab <?php if(($detailtype) == "index"): ?>active<?php endif; ?>"><?php echo L('CONTRACT_DETAILS');?></a></li><?php endif; ?>

				<?php if(!empty($isProductAuthView)): ?><li><a href="<?php echo U('contract/detail',['id'=>encrypt($contract['contract_id'],'CONTRACT'),'detailtype'=>encrypt('product','CONTRACT'),'detail_source'=>$detail_source]);?>" class="form-tab <?php if(($detailtype) == "product"): ?>active<?php endif; ?>"><?php echo L('PRODUCT_DETAILS');?></a></li><?php endif; ?>

				<div class="clear"></div>

			</ul>

		</div>

        <!--<?php echo L('CUSTOMER_DETAIL');?>-->
		<form class="layui-form">

		<div class="form-content form-content1 <?php if(($detailtype) != "index"): ?>hidden<?php endif; ?>">

			<div class="form-item pb25 pt20 border_b">

				<div class="layui-form-item mb10 wd50 fl">

					<label class="layui-form-label"><?php echo L('CONTRACT_NO');?></label>

					<div class="layui-input-inline"><?php echo ($contract["contract_prefix"]); echo ($contract["contract_no"]); ?></div>

					<div class="clear"></div>

				</div>

				<div class="layui-form-item mb10 wd50 fl">

					<label class="layui-form-label"><?php echo L('OWNED_CUSTOMER');?></label>

					<div class="layui-input-inline blue8"><a mini='customer' data-id="<?php echo (encrypt($contract["customer_id"],'CUSTOMER')); ?>" data-type="detailPop" class="blue8 cursor" ><?php echo ($customer['detail']['name']); ?></a></div>

					<div class="clear"></div>

				</div>

				<?php if(!empty($contract["opportunity_id"])): ?><div class="layui-form-item mb10 wd50 fl">

						<label class="layui-form-label"><?php echo L('OWNED_OPPORTUNITY');?></label>

						<div class="layui-input-inline blue8"><a href="javascript:;" onclick="clickOpenDetailByA(this,'opportunity');" data-id="<?php echo (encrypt($contract["opportunity_id"],'OPPORTUNITY')); ?>" data-type="detailPop" class="blue8 cursor" ><?php echo ($opportunity['detail']['name']); ?></a></div>

						<div class="clear"></div>

					</div><?php endif; ?>

				<?php if(is_array($contractform)): $i = 0; $__LIST__ = $contractform;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><!-- 字段未设置查看范围或当前用户角色在查看范围内 -->
					<?php if(!$vo['role_id'] || in_array($index['role_id'],explode(',',$vo['role_id']))): ?><div class="layui-form-item mb10 wd50 fl">

						<label class="layui-form-label"><?php echo ($vo["form_description"]); ?></label>

						<div class="layui-input-inline"><?php echo ((isset($contract['detail'][$vo['form_name']]) && ($contract['detail'][$vo['form_name']] !== ""))?($contract['detail'][$vo['form_name']]):'--'); ?></div>

						<div class="clear"></div>

					</div><?php endif; endforeach; endif; else: echo "" ;endif; ?>

				<?php if(is_array($contractform2)): $i = 0; $__LIST__ = $contractform2;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><!-- 字段未设置查看范围或当前用户角色在查看范围内 -->
					<?php if(!$vo['role_id'] || in_array($index['role_id'],explode(',',$vo['role_id']))): ?><div class="layui-form-item mb10 wd100 layui-form-item-textarea fl">

						<label class="layui-form-label">

							<?php echo ($vo["form_description"]); ?>

						</label>

						<div class="layui-input-inline textareaImg">

							<?php echo ((isset($contract['detail'][$vo['form_name']]) && ($contract['detail'][$vo['form_name']] !== ""))?($contract['detail'][$vo['form_name']]):'--'); ?>

						</div>

						<div class="clear"></div>

					</div><?php endif; endforeach; endif; else: echo "" ;endif; ?>

				<div class="layui-form-item mb10 wd100 layui-form-item-textarea fl">

					<label class="layui-form-label"><?php echo L('SCANNED_COPY_OF_CONTRACT');?></label>

					<div class="layui-input-inline">

						<div class="contractImg" >

							<?php if(is_array($contract["contract_img"])): $i = 0; $__LIST__ = $contract["contract_img"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><div class="layui-upload-drag ">

									<img src="<?php echo ($vo); ?>">

								</div><?php endforeach; endif; else: echo "" ;endif; ?>

						</div>

					</div>

					<div class="clear"></div>

				</div>

				<div class="layui-form-item mb10 wd100 layui-form-item-textarea fl">

					<label class="layui-form-label"><?php echo L('CONTRACT_ATTACHMENT');?></label>

					<div class="layui-input-inline">

						<div class="ticket-file">

							<?php if(empty($contract["createFiles"])): ?><span>--</span>

							<?php else: ?>

								<ul id="attach-ul">

									<?php if(is_array($contract["createFiles"])): $i = 0; $__LIST__ = $contract["createFiles"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><li>

											<span >

												<?php if(in_array(($vo["file_type"]), explode(',',"pdf,txt,doc,docx,xlsx,xls,jpeg,png,gif,jpg,ppt,pptx"))): ?><a class="cursor blue5" href="<?php echo openFile($vo['file_link'],$vo['file_type']);?>" target="_blank"><?php echo (getFileName($vo["file_name"])); ?>.<?php echo ($vo["file_type"]); ?></a>

												<?php else: ?>

													<?php echo (getFileName($vo["file_name"])); ?>.<?php echo ($vo["file_type"]); endif; ?>

											</span>

											<span class="gray4">(<?php echo (getFileSize($vo["file_size"])); ?>)</span>

											<a href="<?php echo ($vo["file_link"]); ?>" title="<?php echo ($vo["file_name"]); ?>" download="<?php echo ($vo["file_name"]); ?>" class="blue8"><i class="iconfont icon-xiazai fts20"></i></a>

										</li><?php endforeach; endif; else: echo "" ;endif; ?>

								</ul><?php endif; ?>

						</div>

					</div>

					<div class="clear"></div>

				</div>

				<div class="clear"></div>

			</div>

			<div class="form-item pb10 pt20">

				<div class="layui-form-item mb10 wd50 fl">

					<label class="layui-form-label">

					   <?php echo L('SUBORDINATE_SECTOR');?>

					</label>

					<div class="layui-input-inline">

						<?php echo CrmgetMemberGroupName($groupList,$contract['group_id']);?>

					</div>

					<div class="clear"></div>

				</div>

				<div class="layui-form-item mb10 wd50 fl">

					<label class="layui-form-label">

					   <?php echo L('CONTRACT_RESPONSIBLE');?>

					</label>

					<div class="layui-input-inline blue8">

						<?php echo ($contract["member_name"]); ?>

					</div>

					<div class="clear"></div>

				</div>

				<div class="layui-form-item mb10 wd50 fl">

					<label class="layui-form-label">

					   <?php echo L('FOUNDER');?>

					</label>

					<div class="layui-input-inline">

						<?php echo ($contract["creater_name"]); ?>

					</div>

					<div class="clear"></div>

				</div>

				<div class="layui-form-item mb10 wd50 fl">

					<label class="layui-form-label">

					   <?php echo L('CREATE_TIME');?>

					</label>

					<div class="layui-input-inline">

						<?php echo (getDates($contract["createtime"])); ?>

					</div>

					<div class="clear"></div>

				</div>

				<div class="layui-form-item mb10 wd50 fl">

					<label class="layui-form-label">

						<?php echo L('ENTRY_METHOD');?>

					</label>

					<div class="layui-input-inline">

						<?php echo getCrmEntryMethod($contract['entry_method']);?>

					</div>

					<div class="clear"></div>

				</div>

				<div class="clear"></div>

			</div>

			<div class="operate-info border_t" id="CrmLogBox">


			</div>

			<script>

				layui.use('flow', function()
				{
					var flow = layui.flow;

					flow.load(
					{
						elem: '#CrmLogBox',
						scrollElem:'.feeldesk-main',
						isAuto:false,
						done: function(page, next)
						{
							var url = "<?php echo (ACTION_NAME); ?>";

							var contract_id = "<?php echo encrypt($contract['contract_id'],'CONTRACT');?>";

							var detailtype = "<?php echo encrypt($detailtype,'CONTRACT');?>";

							var lis = [];

							$.get("<?php echo U('contract/'.ACTION_NAME);?>?id="+contract_id+"&detailtype="+detailtype+"&p="+page+"&request=crmlog", function(data)
							{
								if(data.data  && data.data.length > 0)
								{
									layui.each(data.data, function(index, item)
									{
										var items ='<div class="operate-list">';

										if(item.member.face)
										{
											items += '<img src="' + item.member.face + '" alt="">';
										}
										else
										{
											items += '<img src="/Attachs/face/face.png" alt="">';
										}
										items += '&nbsp;&nbsp;&nbsp;<span class="blue8">'+item.member.name+'</span>';

										items += '<span class="gray9 fts12">&nbsp;• '+item.createtime+'&nbsp;</span>';

										items += '<span>'+item.content+'</span>';

										items += '</div>';

										lis.push(items);
									});

									next(lis.join(''), page < data.pages);
								}
								else
								{
									var items = "";

									lis.push(items);

									next(lis.join(''), page < data.pages);
								}
							});

						}
					});
				});

			</script>

        </div>

		</form>

		<div class="form-content form-content5 <?php if(($detailtype) != "product"): ?>hidden<?php endif; ?>"> <!--产品-->

			<div class="item-list wd100">

				<table class="layui-table" lay-skin="line">

					<thead>

						<tr>

							<th><?php echo L('IMAGES');?></th><th><?php echo L('PRODUCT_NAME');?></th><th><?php echo L('PRODUCT_NUM');?></th><th><?php echo L('PRICE');?></th><th><?php echo L('SELLING_PRICE');?></th><th><?php echo L('NUMBER');?></th>

						</tr>

					</thead>

					<tbody>

						<?php if(empty($product)): ?><tr class="nodata center">

								<td colspan="11">

									<p><i class="iconfont icon-nothing fts20"></i></p>

									<p><?php echo L('NO_DATA');?></p>

								</td>

							</tr>

						<?php else: ?>

							<?php if(is_array($product)): $i = 0; $__LIST__ = $product;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr>

									<td><img src="<?php echo ((isset($vo["product_img"]) && ($vo["product_img"] !== ""))?($vo["product_img"]):'/Public/crm/img/default_pro.png'); ?>" width="40" height="40" /></td>

									<td><?php echo ($vo["detail"]["name"]); ?></td>

									<td><?php echo ($vo["detail"]["product_num"]); ?></td>

									<td><?php echo ($vo["detail"]["list_price"]); ?></td>

									<td><?php echo ($vo["unit_price"]); ?></td>

									<td><?php echo ($vo["num"]); ?></td>

								</tr><?php endforeach; endif; else: echo "" ;endif; endif; ?>

					</tbody>

				</table>

				<div class="right-list-page clearfix"><div class="feeldesk-page"><?php echo ($page); ?></div></div>

			</div>

		</div>

	</div>

</div>
<script type="text/javascript">

	layer.ready(function()
	{
		layer.photos({
		  photos: '.contractImg',
		  shift: 5,
		  shade: [0.8, 'rgba(0,0,0,.8)']
		});

	})

</script>

<script>

	$(function()
	{
		layui.use(['layedit','form'], function()
		{
			var layedit = layui.layedit;

			var commentEditor = layedit.build('commentEditor',{hideTool:['strong','italic','underline','del','|','left','center','right','link','unlink','image','help'], height:120});

			$('.reply-comment,.comment-close').on('click',function()
			{
				$("#comment,.comment-shade").fadeToggle();

				var url = $(this).data('post');

				$('.submit-comment a').unbind('click').on('click',function()
				{
					layedit.sync(commentEditor);

					layer.load(2,{offset:['250px']});

					$.post(url,$('#commentForm').serialize(),function(data)
					{
						if(data.status == 2)
						{
							layer.msg(data.msg,{icon:1,time:1000,offset:['150px']},function()
							{
								window.location.reload();
							});
						}
						else
						{
							layer.closeAll('loading');

							layer.msg(data.msg,{icon:2,time:1500,offset:['150px']});
						}
					},'JSON')
				})
			})
		});
	})

</script>

<script type="text/javascript">

	$('body').find('#closeCustomerDetail').click(function()
	{
		window.parent.postMessage('closeDetail','*');
	});

	window.addEventListener('message', function(e)
	{
		if(e.data)
		{
			window.formCustomer = 1;
		}
	}, false)
	
	$(function(){
		
		var Awidth = $('.form-nav').width();
	
		var linum = $('.form-nav ul').children("li").length;
		
		var liwidth = 130 * linum;
		
		if(Awidth > liwidth)
		{
			$('.form-nav ul').css('min-width',Awidth+'px');
		}
		else
		{
			$('.form-nav ul').css('min-width',liwidth+'px');
		}
		
	})
	
</script>

<script type="text/javascript" src="/Public/js/submitform.js"></script>
<script type="text/javascript">
	
	layui.use('form',function()
	{
		var form = layui.form;
		
		form.render('checkbox');
		
		form.render('radio');
		
		form.render('select');

	})
	
</script>



    </div>

    <script type="text/javascript">

        layer.ready(function()
        {
            layer.photos({
                photos: '.textareaImg',
                shift: 5,
                shade: [0.8, 'rgba(0,0,0,.8)']
            });

        })

    </script>

    <script>

        //客户端
        /*if ( navigator.userAgent.toLowerCase().indexOf('electron/') > -1)
        {
            top.setIframe(document);
        }*/
    </script>

    </body>

</html>